/*
 * @Author: 梓岄 3049738225@qq.com
 * @Date: 2025-11-30 14:52:08
 * @LastEditors: 梓岄 3049738225@qq.com
 * @LastEditTime: 2025-11-30 15:11:58
 * @FilePath: /251130_signal/test2
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<signal.h>
#include<string.h>


void sigcb(int signo)
{
    std::cout<<"接收到信号："<<signo<<std::endl;
}


int main()
{
    struct sigaction sanew,saold;

    memset(&sanew,0,sizeof(sanew));
    sanew.sa_handler=sigcb;

    if(sigaction(SIGINT,&sanew,&saold))
    {
        perror("sigaction");
        return 1;
    }

    while (true)
    {
        std::cout<<"进程正在运行，pid: "<<getpid()<<std::endl;
        sleep(1);
    }

    return 0;
}